﻿
<div ms-controller="W_LCSP">
    <div class="tab-filter-type">
        <div class="oh">
            <h5 class="pull-left tr">全部类别：</h5>
            <ul class="tab-type ft14">
                <li><span ms-class-1="active:listType=='DBSX'" ms-click="ChangeType('DBSX')">待我审批</span></li>
                <li><span ms-class-1="active:listType=='YBSX'" ms-click="ChangeType('YBSX')">我已审批</span></li>
                <li><span ms-class-1="active:listType=='Create'" ms-click="ChangeType('Create')">我创建的</span></li>
            </ul>
        </div>
    </div>
    <div class="default-tab ft14 pt20">
        <table class="table table-striped table-responsive table-hover">
            <thead>
                <tr>
                    <th class="tc width-70">
                        序号
                    </th>
                    <th>标题</th>
                    <th>创建人</th>
                    <th>创建时间</th>
                    <th width="10%">操作</th>
                </tr>
            </thead>
            <tbody ms-if="listType=='DBSX'">
                <tr ms-repeat-item="DSHData.XXFBData">
                    <td class="tc">{{$index+1}}</td>
                    <td> {{item.TypeName}}(新闻公告)</td>
                    <td> {{ComFunJS.convertuser(item.CRUser) }}</td>
                    <td>{{item.CRDate|date("yyyy-MM-dd HH:mm")}}</td>
                    <td>
                        <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="审核" ms-click="XXFBCheck(item)">
                            <i class="iconfont icon-shenhe"></i>
                        </a>
                    </td>
                </tr>
                <tr ms-repeat-item="DSHData.LCSPData">
                    
                    <td class="tc">{{$index+1}}</td>
                    <td> {{item.ProcessName}}</td>
                    <td> {{ComFunJS.convertuser(item.CRUser) }}</td>
                    <td>{{item.CRDate|date("yyyy-MM-dd HH:mm")}}</td>
                    <td>
                        <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="审核" ms-click="ViewForm(item)">
                            <i class="iconfont icon-shenhe"></i>
                        </a>
                    </td>
                </tr>
                <tr ms-repeat-item="DSHData.LCSPModelData">
                    
                    <td class="tc">{{$index+1}}</td>
                    <td>{{item.ProcessName}}(流程审批)</td>
                    <td> {{ComFunJS.convertuser(item.CRUser) }}</td>
                    <td>{{item.CRDate|date("yyyy-MM-dd HH:mm")}}</td>
                    <td>
                        <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="审核" ms-click="ViewFormLCSP(item)">
                            <i class="iconfont icon-shenhe"></i>
                        </a>
                    </td>
                </tr>
                <tr ms-if="DSHData.XXFBData.size()+DSHData.LCSPData.size()+DSHData.LCSPModelData.size()==0">
                    <td></td>
                    <td colspan="4">暂无数据</td>
                </tr>
            </tbody>
            <tbody ms-if="listType=='YBSX'">
                <tr ms-repeat-item="DSHData.LCSPYCLData">
                    
                    <td class="tc">{{$index+1}}</td>
                    <td>{{item.ProcessName}}({{item.TaskState==1?"已审批":(item.TaskState==-1?"已退回":"")}})</td>
                    <td> {{ComFunJS.convertuser(item.CRUser) }}</td>
                    <td>{{item.CRDate|date("yyyy-MM-dd HH:mm")}}</td>
                    <td>
                        <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="查看" ms-click="ViewFormLCSPA(item)">
                            <i class="iconfont icon-look"></i>
                        </a>
                    </td>
                </tr>
                <tr ms-if="DSHData.LCSPYCLData.size()==0">
                    <td></td>
                    <td colspan="4">暂无数据</td>
                </tr>
            </tbody>
            <tbody ms-visible="listType=='Create'">
                <tr ms-repeat-item="DSHData.createLCSP">
                    
                    <td class="tc">{{$index+1}}</td>
                    <td>{{item.ProcessName}}<span ms-if="item.StateName!='-1'">({{item.StateName}})</span> </td>
                    <td> {{ComFunJS.convertuser(item.CRUser) }}</td>
                    <td>{{item.CRDate|date("yyyy-MM-dd HH:mm")}}</td>
                    <td>
                        <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="查看" ms-click="ViewFormLCSPA(item)">
                            <i class="iconfont icon-look"></i>
                        </a>
                    </td>
                </tr>
                <tr ms-if="DSHData.createLCSP.size()>0">
                    <td colspan="6">
                        <div id="pageDiv" class="text-right"></div>
                    </td>
                </tr>
                <tr ms-if="DSHData.createLCSP.size()==0">
                    <td></td>
                    <td colspan="4">暂无数据</td>
                </tr>
            </tbody>
        </table>
        <div class="modal fade" id="SHFBModal" role="dialog">
            <div class="modal-dialog" role="document" style="width: 500px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">审核</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label class="col-xs-3 control-label">意见</label>
                                <input type='text' class='form-control reason' style='width:300px;float:left;' value='同意' />
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-info" id="conaddForder" ms-click="ModifySHStauts(-1)"><i class="fa fa-spinner fa-spin" style="display: none"></i>退&nbsp;&nbsp;回</button>
                        <button type="button" class="btn btn-success" id="conaddForder" ms-click="ModifySHStauts(1)"><i class="fa fa-spinner fa-spin" style="display: none"></i>确&nbsp;&nbsp;认</button>
                    </div>
                </div>
            </div>
        </div>
    </div>


</div>
<script>
    var tempindex = avalon.define({
        $id: "W_LCSP",
        userName: ComFunJS.getnowuser(),
        DSHData: { LCSPData: [], XXFBData: [], LCSPModelData: [], LCSPYCLData: [], createLCSP: [] },//待审核列表
        listType: "DBSX",
        seartype: "",
        SelectType: function (type) {
            tempindex.seartype = type;
        },
        ChangeType: function (type) {
            tempindex.listType = type;
        },
        InitWigetData: function () {

            //流程审批
            $.getJSON('/API/VIEWAPI.ashx?Action=LCSP_GETLCSPLIST_INDEX', {}, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    if (typeof (model) != "undefined") {
                        tempindex.DSHData.LCSPData = resultData.Result;//会议管理，出差请假，用车管理待审批
                    }
                    tempindex.DSHData.LCSPModelData = resultData.Result1; //自定义流程审批待审批管理
                    tempindex.DSHData.LCSPYCLData = resultData.Result2; //流程审批已审批列表
                }
            })
            if (typeof (model) != "undefined") {
                //信息发布待审核
                $.getJSON('/API/VIEWAPI.ashx?Action=XXFB_GETXXFBLIST_DSH', {},function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempindex.DSHData.XXFBData = resultData.Result; //信息发布待审核列表

                    }
                })
            }
            if (tempindex.DSHData.XXFBData.size() + tempindex.DSHData.LCSPData.size() + tempindex.DSHData.LCSPModelData.size() == 0) { model.isnull = true; } else { model.isnull = false; }

            $.getJSON('/API/VIEWAPI.ashx?Action=LCSP_GETLCSPLIST', { p: 1, P1: "1", pagecount: model.page.pagecount }, function (resultData) {
                if (resultData.ErrorMsg == "") {

                    tempindex.DSHData.createLCSP.clear();
                    tempindex.DSHData.createLCSP = resultData.Result;
                    model.page.total = resultData.Result1;
                    laypage({
                        cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                        pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / model.page.pagecount), //通过后台拿到的总页数
                        curr: 1, //初始化当前页
                        skin: 'molv',
                        jump: function (e) { //触发分页后的回调
                            if (e.curr != model.page.pageindex) {
                                $.getJSON('/API/VIEWAPI.ashx?Action=LCSP_GETLCSPLIST', { p: e.curr, P1: "1", pagecount: model.page.pagecount }, function (resultData) {
                                    if (resultData.ErrorMsg == "") {
                                        tempindex.DSHData.createLCSP.clear();
                                        tempindex.DSHData.createLCSP = resultData.Result;
                                    }
                                })
                                model.page.pageindex = e.curr;
                            }
                        }
                    });
                }
            })
          

        },
        CheckXXFBData: {},
        XXFBCheck: function (item) {
            tempindex.CheckXXFBData = item;
            $('#SHFBModal').modal('show');
        },
        ModifySHStauts: function (Status) {//要更新的状态及意见
            var reason = $(".reason").val();
            if (Status == 2 && reason == "同意") {
                reason = "退回";
            }
            $.post("/API/VIEWAPI.ashx?ACTION=XXFB_SHXXFB", { P1: tempindex.CheckXXFBData.ID, P2: Status, jy: reason }, function (result) {
                if (result.ErrorMsg == "") {
                    tempindex.DSHData.XXFBData.forEach(function (val, i) {
                        if (val.ID == tempindex.CheckXXFBData.ID) {
                            tempindex.DSHData.XXFBData.remove(val);
                        }
                    })
                    top.ComFunJS.winsuccess("操作成功");
                    $('#SHFBModal').modal('hide');
                }
            });
        },
        OpenDetail: function (item) {
            if (item.MsgLink) {
                top.ComFunJS.winviewform(item.MsgLink, "查看数据", "1000", "");
            }
        }, ViewFormLCSPA: function (item) {
            //top.ComFunJS.winviewform("/ViewV5/AppPage/APP_ADD_WF.html?FormCode=" + item.ModelCode + "&ID=" + item.ID + "&PIID=" + item.intProcessStanceid + "&PDID=" + item.PDID, item.ProcessName + "表单", "1000", "");
            top.ComFunJS.winviewform("/ViewV5/AppPage/APPVIEW.html?FormCode=" + item.ModelCode + "&ID=" + item.ID + "&PIID=" + item.intProcessStanceid + "&r=" + Math.random(), "查看");
        }, ViewForm: function (item) {
            top.ComFunJS.winviewform("/ViewV5/AppPage/APP_ADD_WF.html?FormCode=" + item.ModelCode + "&ID=" + item.DATAID + "&PIID=" + item.PIID + "&PDID=" + item.PDID, item.ProcessName + "审核表单", "1000", "");
        }, ViewFormLCSP: function (item) {
            top.ComFunJS.winviewform("/ViewV5/AppPage/APP_ADD_WF.html?FormCode=LCSP&ID=" + item.ID + "&PIID=" + item.intProcessStanceid + "&PDID=" + item.PDID, item.ProcessName + "审核表单", "1000", "");
        }
    })


    //# sourceURL=LCSP.js;
</script>
